package objects
{
	import core.Assets;
	
	import flash.geom.Rectangle;
	
	import starling.display.MovieClip;
	import starling.display.Shape;
	import starling.events.Event;
	import starling.textures.Texture;
	
	public class Alien extends MovieClip
	{
		public var displayBounds:Shape;
		
		private var _smallBounds:Rectangle;
		private var _smallBoundsFactor:uint;
		
		
		
		public function Alien(textures:Vector.<Texture> = null, fps:Number=12)
		{
			textures = Assets.atlasTexture.getTextures("enemy1-ship_");
			
			super(textures, fps);
			
			this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		public function destroy():void
		{
			_smallBounds = null;
		}
		
		private function onAddedToStage(e:Event):void
		{
			this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			
			this.pivotX = this.width * 0.5;
			this.pivotY = this.height * 0.5;
			
			createSmallBounds();
		}
		
		private function createSmallBounds():void
		{
			_smallBounds = new Rectangle(this.bounds.x + (_smallBoundsFactor * 0.5),
				this.bounds.y + (_smallBoundsFactor * 0.5),
				this.bounds.width - _smallBoundsFactor, 
				this.bounds.height - _smallBoundsFactor);
			
			// TODO: can't use .addChild() with Starling MovieClip, modify this to sprite and MC to it; might scrap this idea
			/*displayBounds = new Shape();
			displayBounds.graphics.lineStyle(1, 0xff);
			displayBounds.graphics.drawRect(this.bounds.x + 10, this.bounds.y + 10, this.bounds.width - 20, this.bounds.height - 20);
			displayBounds.graphics.endFill();
			this.addChild(displayBounds);*/
		}
		
		public function get smallBounds():Rectangle
		{
			return _smallBounds;
		}
		
		public function set smallBounds(value:Rectangle):void
		{
			_smallBounds = value;
		}
	}
}



































